<template>
    <div class="collect-item" @click="toCollectDetail">
        <div class="body row">
            <div class="cover-img">
                <img :src="item.item.coverImg" />
            </div>
            <div class="content">
                <div class="title text-overflow-ellipsis-1">{{item.item.title}}</div>
                <div class="desc text-overflow-ellipsis-2">{{item.item.desc}}</div>
            </div>
        </div>

        <div class="footer row">
            <div class="type">{{type}}</div>
            <div class="collect-time">{{collectTime}}</div>
        </div>
    </div>
</template>

<script>
import { getDateInfo } from "@/utils/date";
export default {
    props: {
        item: Object
    },
    data() {
        return {};
    },
    computed: {
        type() {
            const type = this.item.type;

            let m = {
                video: "视频",
                article: "文章",
                post: "帖子"
            };

            const str = m[type] || "";
            return str;
        },
        collectTime() {
            const { year, month, day } = getDateInfo(
                this.item.collectTimeStamp
            );
            return `${year}-${month}-${day}`;
        }
    },

    methods: {
        toCollectDetail() {
            const path = this.item.path;
            this.$router.push({ path });
        }
    }
};
</script>


<style lang="less" scoped>
.collect-item {
    padding: 30px 0;
    background: #fff;

    .body {
        width: 100%;
        justify-content: space-between;
        overflow: hidden;

        .cover-img {
            width: 120px;
            height: 120px;
            flex: 0 0 auto;
            margin-right: 30px;

            img {
                width: 100%;
                height: 100%;
                object-fit: cover;
            }
        }

        .content {
            flex: 1 1 auto;
            width: 0;

            .title {
                font-weight: 600;
                font-size: 30px;
                margin-bottom: 10px;
            }
        }
    }

    .footer {
        align-items: center;
        margin-top: 20px;
        font-size: 24px;
        color: #888;

        .type {
            margin-right: 30px;
        }
    }
}
</style>